# -*- coding: utf-8 -*-
"""
@Time:2021/6/24 16:31
@Author:Ming-Log
@File:predict.py
@IDE:PyCharm
"""
from tensorflow import keras
import cv2
import matplotlib.pyplot as plt
import numpy as np
from load_dataset import resize_image

#名称编号
names = {0:'陈义航', 1:'杜海峰', 2:'熊旭东', 3:'徐凯', 4:'杨锦鹏', 5:'朱曜宇'}
# 模型的调用
model1 = keras.models.load_model('./model/face.model.h5')

# 网络的摘要信息
model1.summary()

# 预测一张真实图片
pre_img = cv2.imread('./all_photo/chenyihang/04 (68).jpg')
plt.imshow(pre_img, cmap='gray')
plt.show()

img_res = resize_image(pre_img)

# 在指定的维度上增加一个维度
pre_img = np.expand_dims(img_res, axis=0)

pre_label = model1.predict(pre_img).argmax()
print(names[pre_label])
